package com.xyw.his00.dto;
import com.xyw.his00.pojo.dbpojo.DisposalRequest;
import lombok.Data;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Data
public class DisposalRequestDTO {
    private Integer id;
    private Integer registerId;
    private Integer medicalTechnologyId;
    private String  disposalInfo;
    private String  disposalPosition;
    private String creationTime;
    private Integer disposalEmployeeId;
    private Integer inputdisposalEmployeeId;
    private String disposalTime;
    private String disposalResult;
    private String disposalState;
    private String disposalRemark;
    public static DisposalRequest revert(DisposalRequestDTO disposalRequestDTO)throws NullPointerException{
        return  new DisposalRequest(disposalRequestDTO.getId(),
                disposalRequestDTO.getRegisterId(),
                disposalRequestDTO.getMedicalTechnologyId(),
                disposalRequestDTO.getDisposalInfo(),
                disposalRequestDTO.getDisposalPosition(),
                disposalRequestDTO.getCreationTime()==null?null:  LocalDateTime.parse(disposalRequestDTO.getCreationTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
                disposalRequestDTO.getDisposalEmployeeId(),
                disposalRequestDTO.getInputdisposalEmployeeId(),
                disposalRequestDTO.getDisposalTime()==null?null:  LocalDateTime.parse(disposalRequestDTO.getDisposalTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
                disposalRequestDTO.getDisposalResult(),
                disposalRequestDTO.getDisposalState(),
                disposalRequestDTO.getDisposalRemark());
    }
    public static DisposalRequest[] revert(DisposalRequestDTO[] disposalDTOs){
        if (disposalDTOs == null) {
            return null;
        }
        DisposalRequest[] disposals = new DisposalRequest[disposalDTOs.length];
        for (int i = 0; i < disposalDTOs.length; i++) {
            disposals[i] = revert(disposalDTOs[i]);
        }
        return disposals;
    }
}
